<html>
<meta charset="UTF-8">
<table border="1" >
    <title>计算器</title>
    <tr> <td colspan="5"><input id="result" /></td>
     </tr>
    <tr><td><button onclick="s1()">1</button></td>
        <td><button onclick="s2()">2</button></td>
        <td><button onclick="s3()">3</button></td>
        <td><button onclick="add()">+</button></td>
        <td colspan="3"rowspan="4"><button onclick="qingling()">清零</button></td>
    </tr>
    <td><button onclick="s4()">4</button></td>
    <td><button onclick="s5()">5</button></td>
    <td><button onclick="s6()">6</button></td>
    <td><button onclick="jian()">-</button></td>
    </tr>
    <tr><td><button onclick="s7()">7</button></td>
        <td><button onclick="s8()">8</button></td>
        <td><button onclick="s9()">9</button></td>
        <td><button onclick="cheng()">*</button></td>     </tr>
<tr>
    <td><button onclick="s0()">0</button></td>
    <td><button onclick="dian()">.</button></td>
    <td><button onclick="chu()">/</button></td>
    <td><button onclick="dengyu()">=</button></td></tr>
<script>
   var n1;
   var n2;
  function s1(){
       result.value=result.value+1;
    }
  function s2(){
       result.value=result.value+2;
    }
 function s3(){
       result.value=result.value+3;
    }
 function s4(){
       result.value=result.value+4;
    }
 function s5(){
       result.value=result.value+5;
    }
 function s6(){
       result.value=result.value+6;
    }
 function s7(){
       result.value=result.value+7;
    }
 function s8(){
       result.value=result.value+8;
    }
 function s9(){
       result.value=result.value+9;
    }
 function s0(){
       result.value=result.value+0;
    }
 function dian(){
       if(result.value.indexOf(".")==-1)
  {
           result.value = result.value + ".";
 }
    }
  function add(){
      n1=parseFloat(result.value);

       result.value="";
       n2="jia";
    }
  function jian(){
      n1=parseFloat(result.value);

       result.value="";
       n2="jian";
    }
function cheng(){
      n1=parseFloat(result.value);

       result.value="";
       n2="cheng";
    }
function chu(){
      n1=parseFloat(result.value);

       result.value="";
       n2="chu";
    }
  function dengyu(){
       if(n2=="jia"){
           result.value=n1+parseFloat(result.value);}
       if(n2=="jian"){
           result.value=n1-parseFloat(result.value);}
      if(n2=="cheng"){
           result.value=n1*parseFloat(result.value);}
     if(n2=="chu"){
           result.value=n1/parseFloat(result.value);}

    }
function qingling(){

       result.value="";

    }
</script>
</table>
    </html>